home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / spawn_enemy.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  4.2 KB  |  177 lines

  1. //EDITOR
  2. //place info_waypoints with $targetname spawner and #set X
  3. // place info_waypoint/info_pathnode paths/indivudal nodes with $targetname spawned_path and #set X
  4.  
  5. //SCRIPT
  6. // call "thread global/spawn_enemy.scr::Spawner_INIT" at the start of your script
  7. // to spawn call "thread global/spawn_enemy.scr::runner_spawner X" where X is the number of the set
  8.  
  9.  
  10. //////////////////////////////////
  11. runto_player_spawner local.set local.type local.variable local.type_idle:
  12. if (local.variable != NIL)
  13. {
  14.     level.living_guys[local.variable] ++
  15.     level.total_guys[local.variable] ++
  16. }
  17. level.tempnum++
  18. local.name = "spawned_guy" + level.tempnum
  19.  
  20. for (local.i=1;local.i<level.spawners+1;local.i++)
  21. {
  22.     if( level.spawner[local.i].set == local.set)
  23.     {
  24.         local.spawner = level.spawner[local.i].origin
  25.     }
  26. }
  27. for (local.i=1;local.i<level.spawned_paths+1;local.i++)
  28. {
  29.     if(level.spawned_path[local.i].set == local.set)
  30.     {
  31.         local.spawned_path = level.spawned_path[local.i].origin
  32.     }
  33. }
  34.  
  35. if (local.type == "NIL")
  36.     local.type = 4
  37. switch (local.type)
  38. {
  39. case 1:
  40.     local.enemy_type = "models/human/german_afrika_private"
  41.     break
  42. case 2:
  43.     local.enemy_type = "models/human/german_winter_type1"
  44.     break
  45. case 3:
  46.     local.enemy_type = "models/human/german_wehrmact_officer"
  47.     break
  48. case 4:
  49.     local.enemy_type = "models/human/german_wehrmact_soldier"
  50.     break
  51. default:
  52.     local.enemy_type = "models/human/german_wehrmact_soldier"
  53.     break
  54. }
  55.  
  56.  
  57.  
  58. if (randomint (4) == 1) 
  59.     local.grenades = 4
  60. else
  61.     local.grenades = 0
  62.  
  63. if (randomint (3) == 1) 
  64.     local.gun = "MP40"
  65. else
  66.     local.gun = "Mauser KAR 98K"
  67.  
  68. if (local.type_idle == "idle")
  69.     local.not_run = 1
  70. if (local.type_idle != "runner")
  71.     local.type_idle = "idle"
  72.  
  73. local.maxdist = (160 + randomint (600))
  74. spawn local.enemy_type "targetname" local.name "type_idle" local.type_idle "patrolpath" local.spawned_path "type_attack" "turret" "leash" "10000" "maxdist" local.maxdist "mindist" "128" "ammo_grenade" local.grenades "gun" local.gun
  75. local.name.origin = local.spawner
  76.  
  77. if ((local.type_idle != "runner") &&  (local.not_run != 1))
  78. {
  79.     local.name thread runto_player 160
  80. }
  81.  
  82. if (local.variable != NIL) $(local.name) thread wait_till_dead local.variable
  83. end
  84.  
  85. //////////////////////////////////
  86. idle_spawner local.set local.type local.variable:
  87. local.type_idle = "idle"
  88. thread runto_player_spawner local.set local.type local.variable local.type_idle
  89. end
  90.  
  91.  
  92. //////////////////////////////////
  93. runner_spawner local.set local.type local.variable:
  94. local.type_idle = "runner"
  95. thread runto_player_spawner local.set local.type local.variable local.type_idle
  96. end
  97.  
  98. ////////////////////////
  99. runto_player local.distance:
  100. while (IsAlive self &&  ((vector_length($player.origin - self.origin)) > local.distance))
  101. {
  102. self exec global/runto.scr $player.origin
  103. wait .2
  104. }
  105. end
  106.  
  107. ///////////////////
  108. wait_till_dead  local.variable:
  109. self waittill death
  110. level.living_guys[local.variable] -= 1
  111. end
  112.  
  113.  
  114. /////////////////////////////////////
  115. Spawner_INIT:
  116.  
  117.     if ($spawner == NULL)
  118.         level.spawners = 0
  119.         else
  120.         level.spawners = $spawner.size
  121.  
  122.     if (level.spawners > 0)
  123.     {
  124.         level.spawner = thread global/makearray.scr::main $spawner
  125.  
  126.         for (local.i=1;local.i<level.spawners+1;local.i++)
  127.         {
  128.  
  129.             if (level.spawner[local.i].set == NIL)
  130.                 println "Error, spawner has no #set"
  131.                 else
  132.                 println ("Spawned spawner " + level.spawner[local.i].set)
  133.         }
  134.     }
  135.  
  136.     if ($spawned_path == NULL)
  137.         level.spawned_paths = 0
  138.         else
  139.         level.spawned_paths = $spawned_path.size
  140.  
  141.     if (level.spawned_paths > 0)
  142.     {
  143.         level.spawned_path = thread global/makearray.scr::main $spawned_path
  144.  
  145.         for (local.i=1;local.i<level.spawned_paths+1;local.i++)
  146.         {
  147.  
  148.             if (level.spawned_path[local.i].set == NIL)
  149.                 println "Error, spawned_path has no #set"
  150.                 else
  151.                 println ("Spawned spawned_path " + level.spawned_path[local.i].set)
  152.         }
  153.     }
  154. end
  155.  
  156.  
  157. tracker_INIT local.variable:
  158.     level.total_guys[local.variable] = 0
  159.     level.living_guys[local.variable] = 0
  160. end
  161.  
  162.  
  163. make_array local.object:
  164.     if (local.object.size > 1)
  165.     {
  166.         end local.object
  167.     }
  168.     else if (local.object.size == 1)
  169.     {
  170.         local.array[1] = local.object
  171.         end local.array
  172.     }
  173.     else
  174.     {
  175.         println "Error in make_array for '" local.object.targetname "'"
  176.     }
  177. end